package com.funever.entity;

import java.util.LinkedList;
import java.util.List;

import com.activeandroid.Model;
import com.activeandroid.annotation.Column;
import com.activeandroid.annotation.Table;
import com.activeandroid.query.Delete;
import com.activeandroid.query.Select;

@Table(name = "WorkType")
public class WorkType extends Model{
	
	@Column(name = "name")
	String name;
	@Column(name = "startTime1")
	String startTime1;
	@Column(name = "endTime1")
	String endTime1;
	@Column(name = "startTime2")
	String startTime2;
	@Column(name = "endTime2")
	String endTime2;
	
	
	public static List<WorkType> findAll(){
		List<WorkType> wl = new LinkedList<WorkType>();
		Select select =  new Select();
		wl = select.from(WorkType.class).execute();
		return wl;
	}
	
	public static WorkType findByWhere(String where){
		Select select =  new Select();
		return select.from(WorkType.class).where(where).executeSingle();
	}
	
	public static List<WorkType> findAllByWhere(String where){
		Select select =  new Select();
		return select.from(WorkType.class).where(where).execute();
	}
	
	public static void deleteByWhere(String where){
		new Delete().from(WorkType.class).where(where).execute();
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getStartTime1() {
		return startTime1;
	}

	public void setStartTime1(String startTime1) {
		this.startTime1 = startTime1;
	}

	public String getEndTime1() {
		return endTime1;
	}

	public void setEndTime1(String endTime1) {
		this.endTime1 = endTime1;
	}

	public String getStartTime2() {
		return startTime2;
	}

	public void setStartTime2(String startTime2) {
		this.startTime2 = startTime2;
	}

	public String getEndTime2() {
		return endTime2;
	}

	public void setEndTime2(String endTime2) {
		this.endTime2 = endTime2;
	}
	
	public boolean equals(Object o) {
		WorkType wt = (WorkType) o;
		if(wt.getName().equals(this.name)){
			return true;
		}
		return false;
	}
}
